package com.quickask.interceptor;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

import java.util.Map;

/**
 * Created by NaSa on 2015/9/3.
 */
public class MyInterceptor implements Interceptor {
    @Override
    public void destroy() {

    }

    @Override
    public void init() {

    }

    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        Map sessionMap = actionInvocation.getInvocationContext().getSession();
        String username = (String)sessionMap.get("username");
        if (username != null) {
            return actionInvocation.invoke();
        }
        return Action.ERROR;
    }
}
